import axios from "axios"
const baseURL = "http://localhost:3000"
// axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';

const request = axios.create({
    baseURL,
    timeout:5000,
})

// {username:"zhangsan"}  ---  username=zhagnsan

// 请求 拦截器 ---

// 客户端发请求  --- 请求拦截器  ---- 服务器 
// username:zhangsan   -- username:lisi  ---
//                     token   ----
request.interceptors.request.use(config => {

    // const token = localStorage.getItem("token")
    // config.params = {...config.params,accesstoken:token}
    // config.data = {...config.data,accesstoken:token}
    //必须得有
    // config.data = qs.stringify({...config.data})
    return config
},err => {
    //请求出错的处理函数
    return Promise.reject(err)
})


export default request
